package com.minisoft.exhibition;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.minisoft.enums.AgentTypeEnum;
import org.junit.Test;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author JueSu
 * @description: TODO
 * @date 2023/6/25 16:17
 */
public class FixAppointData {

    public static String DB_CENTER = "center-pro";
    public static String DB_YDAC = "ydac-pro";

    @Test
    public void fixReportId() throws SQLException {
        //城市指定的到访修复customer_report_extra的report_id
        List<Entity> list = Db.use(DB_YDAC).query("select l.id ,l.sale_team_id from exh_appoint_log l");

    }

    @Test
    public void fixSaleTeamId() throws SQLException {
        //根据scene_id修复customer_report_extra的scene_sale_team_id
        List<Entity> list = Db.use(DB_YDAC).query("select l.id ,l.sale_team_id from exh_appoint_log l");
        List<Object[]> params = new ArrayList<>();
        for (Entity entity : list) {
            params.add(new Object[]{entity.getStr("sale_team_id"),entity.getLong("id")});
        }
        Db.use(DB_CENTER).executeBatch("update customer_report_extra set scene_sale_team_id = ? where scene_id = ?",params);
    }

}
